//
//  SettingVC.m
//  NotepadApp
//
//  Created by yobet on 2018/4/12.
//  Copyright © 2018年 HJ. All rights reserved.
//

#import "SettingVC.h"
#import "CategaryVC.h"
#import "CareWeVC.h"
#import "VC_AlarmClock.h"

@interface SettingVC ()
@property(nonatomic,strong) NSArray * dataArray;
@end

@implementation SettingVC
-(NSArray *)dataArray {
    if (!_dataArray) {
        _dataArray = @[@"权限设置",@"类       别",@"时钟提醒",@"清除缓存",@"关于我们"];
    }
    return _dataArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
 
}

-(void)configTableView {
    self.tableViewStyle = UITableViewStylePlain;
    [super configTableView];
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell * cell =[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.textLabel.text = self.dataArray[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row==0) {
        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        if ([[UIApplication sharedApplication]canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
        }
    }else if (indexPath.row==1) {
        [self.navigationController pushViewController:[[CategaryVC alloc]init] animated:YES];
    }else if (indexPath.row==2) {
        VC_AlarmClock *vc_alrmClock = [[VC_AlarmClock alloc] initWithNibName:@"VC_AlarmClock" bundle:nil];
        [self.navigationController pushViewController:vc_alrmClock animated:YES];
    }else if (indexPath.row==3) {
        UIAlertController * alertController =[UIAlertController alertControllerWithTitle:nil message:@"清楚缓存数据" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction * okAction =[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [CommonTools clearFile];
        }];
        UIAlertAction * cancelAction =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        [alertController addAction:okAction];
        [alertController addAction:cancelAction];
        [self presentViewController:alertController animated:YES completion:nil];
        
    }else {
        UIStoryboard *SB= [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        CareWeVC * careWeVC =[SB instantiateViewControllerWithIdentifier:@"CareWe"];
        [self.navigationController pushViewController:careWeVC animated:YES];
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}
@end
